<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">
    <title>MeetSmart - 会议室管理</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/font/bootstrap-icons.css">
    <!-- 引入自定义CSS -->
    <link rel="stylesheet" th:href="@{/css/style.css}">

    <!-- 引入必要的JS库 -->
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
    <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/zh.js"></script>

    <!-- 引入自定义JS -->
    <script th:src="@{/js/app.js}"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <!-- 导航栏代码与dashboard.html相同 -->
</nav>

<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2><i class="bi bi-door-open"></i> 会议室管理</h2>
        <a sec:authorize="hasRole('ADMIN')" th:href="@{/rooms/new}" class="btn btn-primary">
            <i class="bi bi-plus-lg"></i> 添加会议室
        </a>
    </div>

    <div class="card">
        <div class="card-header bg-primary text-white">
            <h5><i class="bi bi-list"></i> 会议室列表</h5>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>名称</th>
                        <th>容量</th>
                        <th>设备</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="room : ${rooms}">
                        <td th:text="${room.id}"></td>
                        <td th:text="${room.name}"></td>
                        <td th:text="${room.capacity}"></td>
                        <td>
                            <span th:if="${room.hasProjector}" class="badge bg-info me-1"><i class="bi bi-projector"></i> 投影仪</span>
                            <span th:if="${room.hasWhiteboard}" class="badge bg-info me-1"><i class="bi bi-easel"></i> 白板</span>
                            <span th:if="${room.hasAudioSystem}" class="badge bg-info"><i class="bi bi-speaker"></i> 音响</span>
                        </td>
                        <td>
                            <span th:if="${room.isActive}" class="badge bg-success">可用</span>
                            <span th:if="${!room.isActive}" class="badge bg-danger">禁用</span>
                        </td>
                        <td>
                            <a th:href="@{'/rooms/' + ${room.id}}" class="btn btn-sm btn-outline-primary me-1">
                                <i class="bi bi-eye"></i> 查看
                            </a>
                            <a sec:authorize="hasRole('ADMIN')" th:href="@{'/rooms/' + ${room.id} + '/edit'}" class="btn btn-sm btn-outline-secondary me-1">
                                <i class="bi bi-pencil"></i> 编辑
                            </a>
                            <a sec:authorize="hasRole('ADMIN')" th:href="@{'/rooms/' + ${room.id} + '/delete'}" class="btn btn-sm btn-outline-danger">
                                <i class="bi bi-trash"></i> 删除
                            </a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>